package cn.edu.ctbu.lab.dao;

import cn.edu.ctbu.lab.domain.Course;
import cn.edu.ctbu.lab.domain.Student;

import cn.edu.ctbu.lab.vo.CourseExt;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;


import java.util.List;

public interface CourseRepository extends JpaRepository<Course,Integer> {



    @Query(value = "SELECT  c.id, c.teacher_id as teacherId, c.course_name as courseName, t.name AS teacherName  " +
              " FROM  tb_course c LEFT JOIN tb_teacher t ON c.teacher_id = t.id  limit :start ,:pageSize ",nativeQuery = true)
    public List<CourseExt> getByPage(Integer start, Integer pageSize);

    @Query(value = "SELECT  count(*)" +
            "FROM \ttb_course c LEFT JOIN tb_teacher t ON c.teacher_id = t.id  ",nativeQuery = true)
    public Integer getByPageCount();



}
